package com.video.service.impl;

import com.video.dao.AdminMapper;
import com.video.entity.Admin;
import com.video.entity.AdminExample;
import com.video.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    public AdminMapper adminMapper;

    @Override
    public List<Admin> findAll() {
        return null;
    }

    @Override
    public Admin selectByAdmin(Admin admin) {
        AdminExample adminExample = new AdminExample();
        AdminExample.Criteria criteria = adminExample.createCriteria();
        criteria.andUsernameEqualTo(admin.getUsername());
        criteria.andPasswordEqualTo(admin.getPassword());
        List<Admin> admins = adminMapper.selectByExample(adminExample);
        if(admins.isEmpty()){
            return null;
        }else {
            return admins.get(0);
        }
    }
}
